<template>
  <!-- 底部导航 -->

  <van-tabbar v-model="active" route active-color="#be3335">
    <van-tabbar-item to="/home" icon="wap-home-o">首页</van-tabbar-item>
    <van-tabbar-item to="/type" icon="point-gift-o">分类</van-tabbar-item>
    <van-tabbar-item to="/cart/edit" :info="num?num:''" icon="cart-o">购物车</van-tabbar-item>
    <van-tabbar-item to="/my/sign" icon="friends-o">我的</van-tabbar-item>
  </van-tabbar>
</template>
<script>
export default {
  props: ["numbers"],
  data() {
    return {
      active: "",
      num: 0
    };
  },
  watch: {
    numbers() {
      // console.log(111);
      this.num = this.numbers;
      // console.log(this.numbers);
    }
  },
  methods: {
    getListNum() {
      let url = "/cart/all";
      this.$axios
        .get(url)
        .then(res => {
          // console.log("res", res);
          let list = res.list;

          list.forEach(item => {
            this.num += item.buyNum;
          });
        })
        .catch(err => {
          console.log("err", err);
        });
    }
  },
  created() {
    this.getListNum();
    // console.log(this.numbers)
  }
};
</script>